package com.problem.leetcode;

/**
 * @author didi
 * @DESCRIPTION
 * @create 2019-04-05 01:57
 **/

public class Problem509 {
    public static void main(String[] args) {
        Problem509 problem509 = new Problem509();
        int        c          = problem509.fib(4);
        System.out.println(c);
    }

    public int fib(int n) {

        if (n == 0){
            return 0;
        }

        int a = 0;
        int b = 1;
        int c = a + b;
        for (int i = 2; i < n; i++) {
            a = b;
            b = c;
            c = a + b;
        }
        return c;
    }

}
